package com.yang.concurrency.chapter3;

/**
 * @Author: 血魔
 * @Date: Created in 14:53 2021/12/12
 * @Version: $
 */
public class CreateThread05 {
    private static int counter = 1;

    public static void main(String[] args) {
        try{
            for (int i = 0; i < Integer.MAX_VALUE; i++) {
                counter++;
                new Thread(new Runnable() {
                    byte[] data = new byte[1024*1024 * 2];
                    @Override
                    public void run() {
                        while(true){
//                            try {
//                                Thread.sleep(1);
//                            } catch (InterruptedException e) {
//                                e.printStackTrace();
//                            }
                        }
                    }
                }).start();
            }
        } catch (Error e) {
            System.out.println(counter);
        }
        System.out.println("Total created thread nums => " + counter);
    }

}
